package com.my.code.samphore;

/**
 * 模拟一个生产代价高昂的对象
 */
public class Fat {
    private volatile double d;
    private static int counter = 0;
    private final int id = counter++;

    public Fat() {
        for (int i = 0; i < 10000; i++) {
            d += (Math.PI + Math.E) / (double) i;
        }
    }

    public void operation() {
        System.out.println("Fat.operation = Fat id is " + id);
    }

    @Override
    public String toString() {
        return "Fat{id=" + id + '}';
    }
}